package com.isorf.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import com.isorf.mapper.advmapper;
import com.isorf.pojo.adv;

import com.isorf.service.advservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class advserviceimpl implements advservice
{
    @Autowired
    private advmapper advmapper;

    @Override
    public Boolean deleteadv(Integer id) {
        int result = advmapper.deleteadv(id);
        return result > 0;
    }



    @Override
    public Boolean batchDelete(List<Integer> id) {
        int result = advmapper.batchDelete(id);
        return result > 0;
    }



    //分页查询

    @Override
    public PageInfo<adv> pageList(int pageNum, int pageSize) {
        // 使用PageHelper.startPage方法设置分页参数
        PageHelper.startPage(pageNum, pageSize);
        // 查询所有用户数据，此时查询会被自动分页
        List<adv> userList = (List<adv>) advmapper.pageList();
        // 使用PageInfo包装查询结果，便于页面使用
        return new PageInfo<>(userList);
    }





    @Override
    public Boolean addadv(adv advs)
    {
        int result = advmapper.addadv(advs);
        if (result > 0) {
            return true;
        } else {
            return false;
        }
    }

}
